<?php

// 获取我的活动列表
// GET activity.me

namespace app\api\resource\activity;
use think\Db;
use think\Session;

class Me
{
    // 方法
    public $_method = ['GET'];
    // 前置
    public $_pre    = [];
    // 描述
    public $_description = '获取我的活动列表';
    // 参数
    public $_param  = [
    ];
    // 返回
    public $_return = [
        200 => '获取成功',
    ];

    public function run(&$request)
    {
        $memberId = Session::get('member.id');

        $list = Db::name('activity_signup')->where('member_id',$memberId)->select();

        $volist = [];
        if ( !empty($list) ) {
            foreach ($list as $key => $val) {
                $volist[$key]['activity'] = Db::name('activity')->where('id',$val['activity_id'])->find();
                if (0 != $val['project_id']) {
                    $volist[$key]['project'] = Db::name('project')->where('id',$val['project_id'])->find();
                }
                $volist[$key]['sign_up_time'] = $val['create_time'];
            }
        }

        return [200,$volist];
    }
}